package com.baizhi;

import com.baizhi.service.BookService;
import com.baizhi.service.CategoryService;
import com.baizhi.service.impl.BookServiceImpl;
import com.baizhi.service.impl.CategoryServiceImpl;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class BookAction {
    private BookService bs=new BookServiceImpl();
    private CategoryService b=new CategoryServiceImpl();
    private List<Book> list;//编辑推荐
    private List<Book> listReXiao;
    private List<Book> date;
    private List<Book> updateBook;
    private Book book;
    private List<Category> cate;
    private Category message;
    private PageInfo<Book> page;
    private int cid;
    private int pageIndex=1;
    private int pageSize;
    private PageInfo<Book> info;
    private int isCateFirst=1;
    private List<Category> categories;
    private String catename;
    private String catesecond;

    public String getCatesecond() {
        return catesecond;
    }

    public void setCatesecond(String catesecond) {
        this.catesecond = catesecond;
    }

    public String getCatename() {
        return catename;
    }

    public void setCatename(String catename) {
        this.catename = catename;
    }

    public List<Category> getCategories() {
        return categories;
    }

    public void setCategories(List<Category> categories) {
        this.categories = categories;
    }

    public int getIsCateFirst() {
        return isCateFirst;
    }

    public void setIsCateFirst(int isCateFirst) {
        this.isCateFirst = isCateFirst;
    }

    public PageInfo<Book> getInfo() {
        return info;
    }

    public void setInfo(PageInfo<Book> info) {
        this.info = info;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getCid() {
        return cid;
    }

    public void setCid(int cid) {
        this.cid = cid;
    }

    public PageInfo<Book> getPage() {
        return page;
    }

    public void setPage(PageInfo<Book> page) {
        this.page = page;
    }

    public Category getMessage() {
        return message;
    }

    public void setMessage(Category message) {
        this.message = message;
    }

    public List<Category> getCate() {
        return cate;
    }

    public void setCate(List<Category> cate) {
        this.cate = cate;
    }

    public Book getBook() {
        return book;
    }

    public void setBook(Book book) {
        this.book = book;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    private int id;
    public List<Book> getUpdateBook() {
        return updateBook;
    }

    public void setUpdateBook(List<Book> updateBook) {
        this.updateBook = updateBook;
    }

    public List<Book> getDate() {
        return date;
    }

    public void setDate(List<Book> date) {
        this.date = date;
    }

    public List<Book> getList() {
        return list;
    }

    public void setList(List<Book> list) {
        this.list = list;
    }

    public List<Book> getListReXiao() {
        return listReXiao;
    }

    public void setListReXiao(List<Book> listReXiao) {
        this.listReXiao = listReXiao;
    }

    public String selectOrder(){
        list = bs.selectOrderById("salenum asc", 2);
        listReXiao = bs.selectOrderById("salenum desc", 8);
        date = bs.selectOrderById("groundingDate desc", 4);
        updateBook = bs.selectOrderById("salenum desc", "groundingDate", 8);
        cate = b.selectCate();
        return "selectSucess";
    }
    public String show(){
         book = bs.selectOne(id);
         message = b.findMessage(id);
         return "showSucess";
    }
    public String pageList() {
        System.out.println(isCateFirst);
        if (isCateFirst == 0) {
            page = bs.PageBook(pageIndex, 5, cid);
            categories=b.selectCateAndCountSecond(cid);
            message=b.selectCate(cid);

            System.out.println(message);
            System.out.println(cid);
            System.out.println(this.categories);
            return "pageSucess";
        }else if (isCateFirst == 1) {
            page = bs.pageFirst(pageIndex, 5, cid);
            categories = b.selectCateAndCount(cid);
            message=b.selectCate(cid);
            System.out.println(message);
            System.out.println(categories);
            System.out.println(cid);
            return "pagefSucess";
        }
        return "sss";
    }

}
